/*
 * Copyright (c) 2020, 2023, 3044483124@qq.com All rights reserved.
 *
 */
package cn.itcast;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;

/**
 * <p>Project: JavaStudy - Img2
 * <p>Powered by jiangbo On 2023-01-05
 * 20:45:16
 * <p>Created by IntelliJ IDEA
 *
 * @author jiangbo [3044483124@qq.com]
 * @version 1.0
 * @since 8/17
 */
public class Img2 {
    public static void main(String[] args) throws Exception {
        int w = 800;
        int h = 800;
        BufferedImage i = new BufferedImage(w, h, 2);
        Graphics2D g = i.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
                RenderingHints.VALUE_STROKE_DEFAULT);
        g.setColor(Color.ORANGE);
        g.fillRect(0, 0, w, h);
        g.setColor(Color.BLACK);
        g.fillArc(200, 200, 400, 400, 90, 180);
        g.setColor(Color.WHITE);
        g.fillArc(200, 200, 400, 400, 270, 180);
        g.fillOval(300, 200, 200, 200);
        g.setColor(Color.BLACK);
        g.fillOval(300, 400, 200, 200);
        g.fillOval(350, 250, 100, 100);
        g.setColor(Color.WHITE);
        g.fillOval(350, 450, 100, 100);
        g.dispose();
        ImageIO.write(i, "png", new File("img2.png"));
        Runtime.getRuntime().exec("cmd /k start img2.png");
    }
}


